package com.zeta.demo.job.common.config;

import com.zeta.api.client.logs.ILogsApi;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.zetaframework.job.event.JobLogListener;


/**
 * 日志事件配置
 *
 * @author gcc
 */
@Slf4j
@Configuration
@RequiredArgsConstructor
public class LogEventConfiguration {

    private final ILogsApi logsApi;

    /**
     * 配置定时日志事件监听 实现
     */
    @Bean
    public JobLogListener jobLogListener() {
        // 远程调用 保存定时任务日志
        return new JobLogListener(logsApi::saveJobLog);
    }
}
